//
//  ZHCollectionReusableView.m
//  LBFacListView_Example
//
//  Created by luckyRoy on 2017/10/23.
//  Copyright © 2017年 luckyBoyRoy@163.com. All rights reserved.
//

#import "ZHCollectionReusableView.h"
#import <Masonry/Masonry.h>

@interface ZHCollectionReusableView ()

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UIButton *clickButton;

@end

@implementation ZHCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createAllView];
    }
    return self;
}

- (void)createAllView
{
    self.titleLabel = [[UILabel alloc]init];
    [self.titleLabel setTextColor:[UIColor redColor]];
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.centerY.equalTo(self);
    }];
    [self addSubview:self.clickButton];
    [self.clickButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(10);
        make.centerY.equalTo(self);
    }];
    
    self.titleLabel.backgroundColor = [UIColor blueColor];
}

#pragma mark - click

- (void)buttonClick:(UIButton *)senter
{
    if (self.fac_clickBlock) {
        self.fac_clickBlock(1);
    }
}

#pragma mark - setter

- (void)fac_updateUIViewByModel:(id)viewModel
{
    NSString *str = viewModel;
    [self.titleLabel setText:str];
}

#pragma mark - getter

- (UIButton *)clickButton
{
    if (!_clickButton) {
        _clickButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_clickButton setTitle:@"下一步" forState:UIControlStateNormal];
        [_clickButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _clickButton.layer.cornerRadius = 6.0;
        _clickButton.backgroundColor = [UIColor blueColor];
        [_clickButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _clickButton;
}

+ (CGFloat)fac_heightForViewByModel:(id)viewModel
{
    CGFloat totalHeight = 44;
    
    return totalHeight;
}


@end
